<?php
include $_SERVER['DOCUMENT_ROOT'].'/config.php';
class DataProvider {
    public static $LAST_INSERT_ID = 0;
    public static function ExecuteQuery($sql) {
        $connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or
                die("couldn't connect to localhost");

        // ebookDB : Tên CSDL   
        mysql_select_db(DB_NAME, $connection);

        mysql_query("set names 'utf8'");

        $result = mysql_query($sql, $connection);
        self::$LAST_INSERT_ID = mysql_insert_id($connection);
        
        mysql_close($connection);

        return $result;
    }

    public static function GetOneRow($sql) {
        $connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or
                die("couldn't connect to localhost");

        // user : Tên CSDL   
        mysql_select_db(DB_NAME, $connection);

        mysql_query("set names 'utf8'");

        $result = mysql_query($sql, $connection);
        $row = mysql_fetch_array($result);

        mysql_close($connection);

        return $row;
    }
	public static function GetOneRowi($sql) {
        $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS,DB_NAME) or die("couldn't connect to localhost");
		
        $result = mysqli_query($connection, $sql);
        $row = mysqli_fetch_array($result, MYSQLI_NUM);

        return $row[0];
    }
}


?> 